package com.intelligentmeterreadingsys.waterlist.reviewdata.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

import com.intelligentmeterreadingsys.R;

/**
 * 复查数据查询条件
 * 
 * @author king
 * 
 */
public class ReviewQueryCondition extends Activity {
	public Button button1;

	public EditText edit1;// 用户编号

	public EditText edit2;// 用户名称

	public EditText edit3;// 水表编号
	public EditText edit4;// 水表地址

	public Spinner spinner;// 抄表状态

	private String usertype;

	public String getUsertype() {
		return usertype;
	}

	public void setUsertype(String usertype) {
		this.usertype = usertype;
	}

	public String[] date = new String[] { "请选择", "未复抄", "已复抄", "二次复抄" };

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		setContentView(R.layout.review_condition);

		inti();
	}

	public void inti() {
		ArrayAdapter<String> ada1 = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, date);
		ada1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		edit1 = (EditText) findViewById(R.id.review_condition_usernumber);
		edit2 = (EditText) findViewById(R.id.review_condition_waterproperties);
		edit4 = (EditText) findViewById(R.id.review_condition_wateradds);
		edit3 = (EditText) findViewById(R.id.review_condition_waternumber);
		spinner = (Spinner) findViewById(R.id.review_condition_copytype);
		spinner.setAdapter(ada1);
		button1 = (Button) findViewById(R.id.review_condition_query);

		edit1.setOnFocusChangeListener(new OnFocusChangeListener() {

			@Override
			public void onFocusChange(View v, boolean hasFocus) {
				if (hasFocus) {
					edit2.setText("");
					edit3.setText("");
					edit4.setText("");
					spinner.setSelection(0, true);
				}

			}
		});

		edit3.setOnFocusChangeListener(new OnFocusChangeListener() {

			@Override
			public void onFocusChange(View v, boolean hasFocus) {
				if (hasFocus) {
					edit2.setText("");
					edit1.setText("");
					edit4.setText("");
					spinner.setSelection(0, true);
				}

			}
		});
		spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> arg0, View arg1,
					int arg2, long arg3) {
				usertype = arg0.getItemAtPosition(arg2).toString();

			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				usertype = "请选择";

			}

		});

		button1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

			}
		});

	}
}
